﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Detail.aspx.cs" Inherits="admin_newsSystem_CommonClass_Detail" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="/admin/Css/Common.css" rel="stylesheet" type="text/css" />
    <script src="/Scripts/jQuery1.7.js" type="text/javascript"></script>
    <script src="/Plugin/artDialog/jquery.artDialog.source.js?skin=blue" type="text/javascript"></script>
    <script src="/Plugin/artDialog/iframeTools.source.js" type="text/javascript"></script>
    <script src="/Plugin/Validform/js/Validform_v4.0.js" type="text/javascript"></script>
    <link href="/Plugin/Validform/css/style.css" rel="stylesheet" type="text/css" />
    <script src="/Scripts/sjn.1.js" type="text/javascript"></script>
    <script src="/Plugin/jqueryEasyui/jquery.easyui.min.js" type="text/javascript"></script>
    <link href="/Plugin/jqueryEasyui/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="/Plugin/jqueryEasyui/themes/icon.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .tbForm tr
        {
            height: 40px;
        }
    </style>
    <script language="javascript" type="text/javascript">

        var editData = null, fun,cid;
        var win = art.dialog.open.origin;
        fun = myurl().attr("fun");
        cid = myurl().attr("cid");
        if (fun != null) {
            //不为空时为编辑状态
            editData = art.dialog.data("editData");
        }


        //页面加载
        $(function () {

            //初始化表单提交
            $(".registerform").Validform({
                tiptype: 2,
                postonce: true,
                ajaxPost: true,
                callback: function (data) {
                    if (data.status == "y") {
                        alert(data.info);
                        win.ClsType_onSelect(null);
                        art.dialog.close();  //提交成功，关闭弹出框
                    } else {
                        alert(data.info);
                    }
                }
            });


            //只绘制TreeGrid 不加载数据，加载数据再绘制完成后加载
            $('#tg').treegrid({
                //url: 'Index.aspx?fun=GetClass&root=' + editData.CCType,
                title:"请选择父类",
                idField: 'ID',
                treeField: 'Name',
                height: 250,
                columns: [[
                            { title: '分类名称', field: 'Name', width: 260 },
                            { title: '深度', field: 'Depth', width: 80 }
                        ]],
                onClickRow: tg_onClickRow,
                onLoadSuccess: function (row, data) {
                    if (data.length > 0) {
                        if (editData != undefined && editData != null) {
                            //当有数据时，默认选择中第一行
                            $('#tg').treegrid("select", editData.PID);
                            var r = $('#tg').treegrid("find", editData.PID);
                            tg_onClickRow(r);
                        } else {
                            //当有数据时，默认选择中第一行
                            $('#tg').treegrid("select", data[0].ID);
                            var r = $('#tg').treegrid("find", data[0].ID);
                            tg_onClickRow(r);
                        }
                    }
                }
            });


            //分类类型 数据加载
            $("#iptClsType").combobox({
                valueField: 'ID',
                textField: 'Name',
                url: 'index.aspx?fun=GetClassType',
                onSelect: ClsType_onSelect,
                onLoadSuccess: function () {
                    //当typeid不为null只 初始化选择项
                    if (editData != null && editData.CCType != undefined && editData.CCType != null) {
                        $("#iptClsType").combobox("select", editData.CCType);
                    } else {
                        $("#iptClsType").combobox("select", $("#iptClsType").combobox("getData")[0].ID);

                    }
                }
            });

            if (editData != undefined && editData != null) {
                $("#CCOrder").val(editData.Order);
                $("#CCID").val(editData.ID);
                $("#CCName").val(editData.Name);
            }

        });    //readload 结束

        //分类选择事件重新加载列表中数据
        var ClsType_onSelect = function (rec) {
            //重新加载数据
            $('#tg').treegrid({ url: 'Index.aspx?fun=GetClass&type=' + rec.ID + '&cid=' + cid + '&root=' });
        }

        //行 click事件
        var tg_onClickRow = function (row) {
            $("#Pname").val(row.Name);
            $("#CCPID").val(row.ID);
            $("#CCType").val(row.CCType);
            $("#Pname").blur();
        }
    </script>
</head>
<body>
    <form id="form1" class="registerform" runat="server">
    <div style="width: 790px; margin: 0 auto;">
        <div style="height: 26px;">
            <span>分类类型：</span><input id="iptClsType" class="easyui-combobox" name="dept">
        </div>
        <div id="divParent" style="width: 410px; height: 260px; float: left;">
            <table id="tg" class="easyui-treegrid">
            </table>
        </div>
        <div id="divForm" style="width: 370px; height: 260px; float: left; margin-left: 10px;">
            <table class="tbForm">
                <tr>
                    <td>
                        <span style="color: Red">*&nbsp;</span>所属父类：
                    </td>
                    <td style="padding-right: 7px;">
                        <input type="text" id="Pname" disabled="disabled" readonly="readonly" name="Pname" class="inputxt" datatype="*1-40"
                            nullmsg="请选择所属上级菜单" errormsg="长度为1~40，请输入正确的字符串长度" style="width: 130px;" />
                        <input type="hidden" id="CCPID" name="CCPID" />
                    </td>
                    <td>
                        <div class="Validform_checktip">
                            请选择父级分类
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <span style="color: Red">*&nbsp;</span>分类名称：
                    </td>
                    <td style="padding-right: 7px;">
                        <input type="text" id="CCName" name="CCName" class="inputxt" ajaxurl="detail.aspx?fun=validUserName" datatype="*1-40" nullmsg="请输入分类名称！"
                            errormsg="长度为1~40的，请输入正确的字符串长度" style="width: 130px;" />
                    </td>
                    <td>
                        <div class="Validform_checktip">
                            请输入分类名称
                        </div>
                    </td>
                </tr>
            </table>
        </div>
        <div class="aui_buttons clear" style="height: 30px;">
            <button id="c_ok" class="aui_state_highlight"  type="submit" style="float: right;">
                <%=btn_text %>
            </button>
            <asp:HiddenField ID="fun" Value="" runat="server" />
            <input type="hidden" id="CCOrder" name="CCOrder" value="" />
            <input type="hidden" id="CCID" name="CCID" value="" />
            <input type="hidden" id="CCType" name="CCType" value="" />
        </div>
    </div>
    </form>
</body>
</html>
